package com.hf.eagle.web.struts;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.hf.eagle.domain.Accessory;
import com.hf.eagle.domain.SaleGrid;
import com.hf.eagle.web.base.BaseAction;
import com.hf.eagle.web.base.SysConstant;

/**
 * 联系我们
 * 
 * @author xiaokeheng
 */
public class ConnectUsAction extends BaseAction {

	public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		return this.view(mapping, form, request, response);
	}

	/**
	 * 显示联系我们
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		SaleGrid saleGrid = new SaleGrid();
		saleGrid.setIs_del(0);
		List<SaleGrid> saleGrids = super.getFacade().getSaleGridService().getSaleGridList(saleGrid);
		if (null != saleGrids && saleGrids.size() > 0) {
			for (SaleGrid sale_grid : saleGrids) {
				if (null != sale_grid) {
					Accessory acce = new Accessory();
					acce.setFile_level(SysConstant.SUB_IMG);
					acce.getMap().put("mod_id", "2400");
					acce.getMap().put("record_id", sale_grid.getGrid_id());
					acce = super.getFacade().getAccessoryService().getAccessory(acce);
					sale_grid.setAccessory(acce);
				}
			}

			Long office_id = saleGrids.get(saleGrids.size() - 1).getGrid_id();
			request.setAttribute("office_id", office_id);
		}

		request.setAttribute("saleGrids", saleGrids);
		return mapping.findForward("view");
	}
}